package dropoffdesk;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Random;

public class DeskController {

	DeskGUI deskGUI;
	DropOffDesk desk;

	public DeskController(DeskGUI deskGUI, DropOffDesk desk) {
		this.deskGUI = deskGUI;
		this.desk = desk;
		desk.setIsOpen(false);
		deskGUI.setVisible(true);
		deskGUI.addCloseDeskButtonListener(new CloseDeskController());

		Random random = new Random();
		Thread thread = new Thread(desk);
		try {
			Thread.sleep(random.nextInt(10000));
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		thread.start();
		desk.setIsOpen(true);

	}

	class CloseDeskController implements ActionListener {
		public void actionPerformed(ActionEvent e) {
			desk.setIsOpen(false);

		}
	}

}
